Fix mesh-normal-vector benchmark array access #1514
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
mesh-normal-scalar correctly fills sequential values in the output for triangle cone function, but mesh-normal-vector accidentally reuses the loop index, which results in writes to every third index of the array (1, 4, etc.).
This is both slower (as the table turns into a hash map), and incorrect, especially as we have a scalar version of the benchmark that does the right thing.
Note: there's a bunch of inefficiencies in the benchmark code that I have not fixed (around field access mostly, e.g. writing to
v.n
and then immediately reading it again). These are not ideal for performance, but they can be valuable to keep as is because this redundancy is common in real-world code, and it would be nice to see codegen optimizations eliminating most of that overhead. This one, however, is a straight up bug, and sparse arrays should not really be the thing this benchmark hits.